/*
 * DetallesForm.java
 *
 * Created on 13 de julio de 2008, 00:58
 */

package View;

import Model.Cliente;
import Model.Detalle;
import Servicio.Proxy;

/**
 *
 * @author  Gigin
 */
public class DetallesForm extends javax.swing.JDialog {
    private Detalle mDetalle;
    private ClientesForm frClientes;
    private RPedidoForm frRPedido;
   
    /** Creates new form DetallesForm */
    public DetallesForm(java.awt.Frame parent, boolean modal,Cliente cli, ClientesForm frameCli, RPedidoForm framePed) {
        
        super(parent, modal);
        initComponents();
        
        this.frClientes = frameCli;
        this.frRPedido=framePed;
        
        mDetalle = Proxy.detallesCliente(cli);
        if (mDetalle == null)
            noExisteCliente();
        else
            existeCliente(cli);
    }

    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabelNombre = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabelFecha = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabelCantidad = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabelTotal = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jLabelNoExiste = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Monotype Corsiva", 1, 24)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(94, 148, 189));
        jLabel1.setText("Historial de pedidos del cliente");

        jLabel2.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        jLabel2.setText("NOMBRE:");

        jLabelNombre.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabelNombre.setText("jLabel3");

        jLabel4.setFont(new java.awt.Font("Verdana", 1, 11));
        jLabel4.setText("FECHA DE ALTA:");

        jLabelFecha.setFont(new java.awt.Font("Verdana", 0, 10)); // NOI18N
        jLabelFecha.setText("jLabel5");

        jLabel6.setFont(new java.awt.Font("Verdana", 1, 11));
        jLabel6.setText("CANTIDAD DE DVDS COMPRADOS:");

        jLabelCantidad.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabelCantidad.setText("jLabel7");

        jLabel8.setFont(new java.awt.Font("Verdana", 1, 11));
        jLabel8.setText("TOTAL GASTADO:");

        jLabelTotal.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabelTotal.setText("jLabel9");

        jButton2.setFont(new java.awt.Font("Verdana", 1, 10)); // NOI18N
        jButton2.setForeground(new java.awt.Color(94, 148, 189));
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_normal.gif"))); // NOI18N
        jButton2.setToolTipText("Volver a la pantalla anterior");
        jButton2.setBorderPainted(false);
        jButton2.setContentAreaFilled(false);
        jButton2.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_deshabilitado.gif"))); // NOI18N
        jButton2.setFocusPainted(false);
        jButton2.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_presionado.gif"))); // NOI18N
        jButton2.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_mouse.gif"))); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabelNoExiste.setFont(new java.awt.Font("Verdana", 2, 10)); // NOI18N
        jLabelNoExiste.setForeground(new java.awt.Color(255, 0, 0));
        jLabelNoExiste.setText("jLabel3");

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/logo_GTV4.gif"))); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(33, 33, 33)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabelFecha))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabelTotal))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel6)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabelCantidad))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel2)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabelNombre))
                                    .addComponent(jLabelNoExiste))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel3))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(140, 140, 140)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(24, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabelNoExiste)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(jLabelNombre))
                        .addGap(7, 7, 7)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelFecha))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(jLabelCantidad))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(jLabelTotal))
                        .addGap(54, 54, 54)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


 private void noExisteCliente(){
        jLabelNombre.setText(" - ");
        jLabelFecha.setText(" - ");
        jLabelCantidad.setText(" - ");
        jLabelTotal.setText(" - ");
        jLabelNoExiste.setText("EL CLIENTE NO TIENE PEDIDOS AÚN");
    }
    
    private void existeCliente(Cliente cli){
        String dia = mDetalle.getFechaInicial().substring(8, 10);  
        String mes = mDetalle.getFechaInicial().substring(5, 7);
        String anio = mDetalle.getFechaInicial().substring(0, 4);
        
        String fecha = dia+"/"+mes+"/"+anio;
        
        
        jLabelNombre.setText(cli.getApellidoCli() + ", "+ cli.getNombreCli());
        jLabelFecha.setText(fecha);
        jLabelCantidad.setText(String.valueOf(mDetalle.getCantidad()));
        jLabelTotal.setText("$" + String.valueOf(mDetalle.getTotalGastado()));
        jLabelNoExiste.setText("");
    
    }

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    this.dispose();
}//GEN-LAST:event_jButton2ActionPerformed

     
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabelCantidad;
    private javax.swing.JLabel jLabelFecha;
    private javax.swing.JLabel jLabelNoExiste;
    private javax.swing.JLabel jLabelNombre;
    private javax.swing.JLabel jLabelTotal;
    // End of variables declaration//GEN-END:variables

}
